<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>黑客帝国文字雨</title>
    <style>
        body {
            margin: 0;
            height: 100vh;
            overflow: hidden;
            background: black;
            color: #00ff00;
            font-family: monospace;
            font-size: 16px;
        }
        canvas {
            display: block;
        }
    </style>
</head>
<body>
    <canvas id="matrixRain"></canvas>

    <script>
        const canvas = document.getElementById('matrixRain');
        const ctx = canvas.getContext('2d');

        // Set canvas to full screen
        canvas.width = window.innerWidth;
        canvas.height = window.innerHeight;

        // Characters to display
        const characters = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz';
        const charArray = characters.split('');
        const fontSize = 16;
        const columns = canvas.width / fontSize;

        const drops = [];

        // Initialize drops array
        for (let x = 0; x < columns; x++) {
            drops[x] = Math.random() * canvas.height / fontSize;
        }

        // Draw the characters
        function draw() {
            ctx.fillStyle = 'rgba(0, 0, 0, 0.05)';
            ctx.fillRect(0, 0, canvas.width, canvas.height);

            ctx.fillStyle = '#00ff00';
            ctx.font = fontSize + 'px monospace';

            for (let i = 0; i < drops.length; i++) {
                const text = charArray[Math.floor(Math.random() * charArray.length)];
                ctx.fillText(text, i * fontSize, drops[i] * fontSize);

                // Reset drop to top if it's off the screen
                if (drops[i] * fontSize > canvas.height && Math.random() > 0.975) {
                    drops[i] = 0;
                }

                // Move drop downwards
                drops[i]++;
            }
        }

        setInterval(draw, 33);

        // Handle window resizing
        window.addEventListener('resize', () => {
            canvas.width = window.innerWidth;
            canvas.height = window.innerHeight;
        });
    </script>
</body>
</html>
